<?php
/**
 * RUBIK IT Solution & Development ltd.
 *
 * PROJECT		: Rubik Ultimate
 * @version 	: 1.1
 * COPYRIGHT	: 2008
 * ------------------------------------------------------
 * 
 * [GENERAL INFO OF THIS FILE] 
 *
 * @author			hoadn <hoadn@rubik.com.vn>
 * @access			[public/private]
 * @package		 [package name]
 *
 * Created on	:Sep 19, 2008
 */

// no direct access
defined ( '_FW_EXEC' ) or die ( 'Restricted access' );

RCoreImporter::cls('html.fieldInfo.AbstractHtmlFieldInfo');

class BooleanHtmlFieldInfo extends AbstractHtmlFieldInfo {

	/**
	 * Function for geting the html for inputing data
	 *
	 * @abstract 
	 * @return string
	 */
	function getHtmlInputData($dataType = '', $extAttribute = '') {
		$extAttribute .= $this->buildValidateHtmlAttribute($dataType);
		$value = htmlspecialchars($this->_value);
		if ($value) {
			$checkBox = 'checked="checked"';
		}
		$inputHtml = "<input {$checkBox} type=\"checkbox\" {$extAttribute} name=\"{$this->_fieldName}\" id=\"{$this->_fieldName}\" value=\"1\" />";
		return $inputHtml;
	}
	
	/**
	 * Function for geting the html for inputing data
	 * NOTE: please override in case special treat
	 * 
	 * @return string
	 */
	function getHtmlFilterData($dataType = '', $extAttributes = '') {
		$extAttributes .= $this->buildValidateHtmlAttribute($dataType);
		$value = htmlspecialchars($this->_value);
		$array = array(''=>"-- Select filter --", '0' => 'False', '1' => 'True');
		$inputHtml = RHtmlHelper::createSelectHtml($this->_fieldName, $array, $this->_value, $extAttributes);
		return $inputHtml;
	}
	
	/**
	 * Build the html for previewing the data
	 * NOTE: please override in case special treat
	 * 
	 * @param string $extAttributes
	 * @return string
	 */
	function buildHtmlPreviewData($extAttributes = '', $key=null, $dataType ='S') {
		if ($this->_value) {
			$cls = 'class="bool_true"';
		}
		else {
			$cls = 'class="bool_false"';
		}
		return "<span {$cls}>&nbsp;</span>";
	}
}
?>